package com.jason.www.services;


import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Build;

import androidx.core.app.NotificationCompat;
import cn.jpush.android.service.JCommonService;

public class PushService extends JCommonService {

    private final String TAG = PushService.class.getSimpleName();

    private void setNotification(){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

            NotificationChannel channel = new NotificationChannel("1001", "推送服务", NotificationManager.IMPORTANCE_LOW);

            NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            if (manager != null) {
                manager.createNotificationChannel(channel);

                Notification notification = new NotificationCompat.Builder(this, "jpush_channel")
                        .setAutoCancel(true)
                        .setCategory(Notification.CATEGORY_SERVICE)
                        .setOngoing(true)
                        .setPriority(NotificationManager.IMPORTANCE_LOW)
                        .build();

                startForeground(101, notification);
            }

        }
    }

}
